﻿using System;
using Nemerle.Collections;
using Nemerle.Utility;

namespace Nemerle.Xml
{
  /// <summary>
  /// Base of any xml element
  /// </summary>
  public abstract class ElementBase : IEquatable[ElementBase]
  {
    protected static _refCmpFunc : object * object -> bool = object.ReferenceEquals;

    /// <summary>
    /// Transforms element. Return 'null' from transform func to delete some element.
    /// </summary>
    public abstract Transform(transform : ElementBase -> ElementBase) : ElementBase;

    public override ToString() : string { Context.Default.ToString(this, false) }

    public abstract Equals(other : ElementBase) : bool implements IEquatable[ElementBase].Equals;

    public override Equals(other : object) : bool
    {
      | node is ElementBase => Equals(node);
      | _                   => false
    }
  }
}
